package Person;

public class Main {

    private static void needExam(Person person){
        if (person instanceof Teacher || person instanceof Student){
            System.out.println("该对象为学生或者老师，可以参加考试");
        }else {
            System.out.println("该对象为工人，不能参加考试");
        }
    }
    public static void main(String[] args) {
        Person person = new Worker();
        Person person1 = new Student();
        needExam(person);
        needExam(person1);

    }
}
